


dojo.require("dojo.data.ItemFileReadStore");

var strDomain = "preop";
var siteId = getParameter("siteId");
var centerId = getParameter("centerId");
var sexId = getParameter("sexId");
var partnerId = getParameter("partnerId");
var relProdId = getParameter("relProdId");
var prodId = getParameter("prodId");
var secId = getParameter("secId");
var spotId = getParameter("spotId");
var hideNav = getParameter("hideNav");
var mediaType = getParameter("mediaType");
var emailId = getParameter("emailId");
var affId = getParameter("affId");
var campId = getParameter("campId");

var visualIds = visualIds + "&hideNav=" + hideNav;
var marketingIds = marketingIds + "&emailId=" + emailId + "&affId=" + affId + "&campId=" + campId;
var centerQueryString = "&centerId=" & centerId
var relQueryString = "&relProdId=" & relProdId

var headerType = "true";

// a very common method of loading code onLoad
var init = function(){
    console.log("init");	
};

dojo.addOnLoad(init);
// Dojo Imports Here



dojo.addOnLoad(function(){
	console.log("addOnLoad");
	getResponseObject();
	updateHeaderType();
	writePageHeader();
	writePageFooter();
	initPageMethods();	
});

function getParameter( name ) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null ){
		return "";
	} else {
		return results[1];
	}
}


function getResponseObject() {
  console.info("getResponseObject");
  dojo.xhrGet({
    url: "../json/partners/www.xml.json",
    load: function(responseObject, ioArgs){
	console.info("getResponseObject:load");

	var jsDir = responseObject.jsDir;
	var cssDir = responseObject.cssDir;
	var partnerName = responseObject.name;
	setPageTitle(responseObject.headerName);
	var headerType = responseObject.headerType;
	var showads = responseObject.showads;
	var questionOn = responseObject.questions;
	var partnerId = responseObject.partnerId;
	var postcare = responseObject.postcare;
	var prodLayout = responseObject.prodLayout;
	
	return responseObject;
    },
    error: function(response, ioArgs){
	console.info("getResponseObject:error");
	console.error(error);
    return response;
    },
   handleAs: "json"
  });
}

var setPageTitle = function(headerName){
	var myDate=new Date();
	dojo.byId("pageTitle").innerHTML =  headerName + '<br><font class="smlgray">' + myDate + '</font>';	
}

function updateHeaderType(){
	if (relProdId != ""){
		headerType = "relation"
	}
}

function initSexId(){
	if (sexId != ""){
		sexId = "male"
	}
}



	/*
	set navlink = PartnavDocRoot.getElementsByTagName("navlink")
	set navdrop = PartnavDocRoot.getElementsByTagName("navdrop")
	set centerLink = PartnavDocRoot.getElementsByTagName("centerLink")
	set prodLink = PartnavDocRoot.getElementsByTagName("prodLink")


	
	relQueryString = "&relProdId=" & relProdId
	if relProdId <> "" Then
		headerType = "relation"
	end if	

	*/